#!/bin/bash

#NOTE!!!! running under bash recommended.
#         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#                       ^^^^


#When mpiexec hangs, type ctrl-C to execute exithandler


trap exithandler TERM INT
exithandler()
{
   /bin/cat itrace* > ./trace
   /bin/rm -rf ./itrace*

   /bin/cat ./iexec_report* > ./exec_report
   /bin/rm -rf ./iexec_report*
   more ./exec_report

   echo "Received ctrl-C: quiting"
   exit 1
}


/bin/rm -rf ./trace
/bin/rm -rf ./exec_report
/home/adamo/mpich2-1.0.6p1-install/bin/mpiexec -np $1 ./exe
/bin/cat ./itrace* > ./trace
/bin/rm -rf ./itrace*

/bin/cat ./iexec_report* > ./exec_report
/bin/rm -rf ./iexec_report*
more ./exec_report

